package ATM;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuJpanel extends JPanel implements ActionListener {
    private ATMJframe atmJframe;
    private JButton btnSave;
    private JButton btnGet;
    private JButton btnFind;
    private JButton btnOff;
    private JButton btnModify;
    private JButton btnPane;
    private JLabel transfer;
    private Icon buttonSave = Util.getimagesIcon("/images/buttonSave.jpg");
    private Icon buttonGet = Util.getimagesIcon("/images/buttonGet.jpg");
    private Icon buttonFind = Util.getimagesIcon("/images/buttonFind.jpg");
    private Icon buttonOff = Util.getimagesIcon("/images/buttonOff.jpg");
    private Icon buttonModify = Util.getimagesIcon("/images/buttonModify.jpg");
    private Icon buttonPane = Util.getimagesIcon("/images/pane.jpg");

    public MenuJpanel(ATMJframe atmJframe) {
        this.atmJframe = atmJframe;
        this.setLayout(null);
        this.setOpaque(false);
        btnSave = new JButton("", buttonSave);
        btnSave.setBounds(200, 150, 140, 50);
        this.add(btnSave);
        btnSave.addActionListener(this);
        btnGet = new JButton("", buttonGet);
        btnGet.setBounds(200, 350, 140, 50);
        this.add(btnGet);
        btnGet.addActionListener(this);
        btnFind = new JButton("", buttonFind);
        btnFind.setBounds(200, 550, 140, 50);
        this.add(btnFind);
        btnFind.addActionListener(this);

        btnOff = new JButton("", buttonOff);
        btnOff.setBounds(850, 550, 140, 50);
        this.add(btnOff);
        btnOff.addActionListener(this);


        btnModify = new JButton("", buttonModify);
        btnModify.setBounds(850, 350, 140, 50);
        this.add(btnModify);
        btnModify.addActionListener(this);

        transfer = new JLabel("转  账");
        transfer.setBounds(885, 150, 140, 50);
        transfer.setFont(new Font("宋体", Font.LAYOUT_NO_LIMIT_CONTEXT, 25));
        transfer.setForeground(Color.WHITE);
        this.add(transfer);

        btnPane = new JButton("转账", buttonPane);
        btnPane.setBounds(850, 150, 140, 50);
        this.add(btnPane);
        btnPane.setOpaque(false);
        btnPane.addActionListener(this);


    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (btnSave == e.getSource()) {

            atmJframe.switchPanel("save");
        } else if (btnGet == e.getSource()) {

            atmJframe.switchPanel("get");
        } else if (btnFind == e.getSource()) {
            atmJframe.setFindJpanel();
            atmJframe.switchPanel("find");
        } else if (btnOff == e.getSource()) {
            atmJframe.switchPanel("log");

        }else if (btnPane==e.getSource()){
            atmJframe.switchPanel("trans");

        }else if (btnModify==e.getSource()){
            atmJframe.switchPanel("modify");

        }
    }


}
